"use strict";
const t = require("../common/vendor.js"),
	e = require("./qqmap-wx-jssdk.js"),
	o = require("./my-account.js");
var n;
n = new e.QQMapWX({
	key: o.LBS_KEY
});

function i(t, e) {
	return new Promise(((o, i) => {
		n.reverseGeocoder({
			location: {
				latitude: t,
				longitude: e
			},
			success: t => {
				const e = t.result.address_component.city,
					n = t.result.location;
				o({
					city: e,
					latitude: n.lat,
					longitude: n.lng
				})
			},
			fail: t => {
				o({
					city: "昆明市",
					latitude: 25.01503,
					longitude: 102.7437
				})
			}
		})
	}))
}
exports.addressCity = i, exports.getLocation = function() {
	return new Promise(((e, o) => {
		t.wx$1.startLocationUpdate({
			type: "wgs84",
			success: o => {
				t.wx$1.onLocationChange((async o => {
					t.wx$1.stopLocationUpdate();
					const n = await i(o.latitude, o.longitude);
					e(n)
				}))
			},
			fail: o => {
				console.log("用户关闭定位"), t.wx$1.offLocationChange(), e({
					city: "昆明市",
					latitude: 25.01503,
					longitude: 102.7437
				})
			}
		})
	}))
};